package net.lgpage.tool;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Administrator on 2015/11/20.
 */
public class GsonObj implements Parcelable {
    Class objclass;
    String gsonstring;
    public Class getObjclass() {
        return objclass;
    }
    public void setObjclass(Class objclass) {
        this.objclass = objclass;
    }
    public String getGsonstring() {
        return gsonstring;
    }
    public void setGsonstring(String gsonstring) {
        this.gsonstring = gsonstring;
    }
    public GsonObj(Object obj) {
        objclass = obj.getClass();
        gsonstring = GsonTool.getGson().toJson(obj);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeSerializable(this.objclass);
        dest.writeString(this.gsonstring);
    }

    protected GsonObj(Parcel in) {
        this.objclass = (Class) in.readSerializable();
        this.gsonstring = in.readString();
    }

    public static final Parcelable.Creator<GsonObj> CREATOR = new Parcelable.Creator<GsonObj>() {
        public GsonObj createFromParcel(Parcel source) {
            return new GsonObj(source);
        }

        public GsonObj[] newArray(int size) {
            return new GsonObj[size];
        }
    };
}
